package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CustomerShopCart;
import com.pgybook.db.entity.domain.CustomerShopCartEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CustomerShopCartMapper {
    int countByExample(CustomerShopCartEx example);

    int deleteByExample(CustomerShopCartEx example);

    @Delete({
            "delete from customershopcart",
            "where CUSTSHOPCARTID = #{custshopcartid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long custshopcartid);

    @Insert({
            "insert into customershopcart (CUSTID, LIBID, ",
            "BOOKID, INSTANCEID, ",
            "CRTTIME)",
            "values (#{custid,jdbcType=BIGINT}, #{libid,jdbcType=INTEGER}, ",
            "#{bookid,jdbcType=BIGINT}, #{instanceid,jdbcType=BIGINT}, ",
            "#{crttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "custshopcartid", before = false, resultType = Long.class)
    int insert(CustomerShopCart record);

    int insertSelective(CustomerShopCart record);

    List<CustomerShopCart> selectByExample(CustomerShopCartEx example);

    @Select({
            "select",
            "CUSTSHOPCARTID, CUSTID, LIBID, BOOKID, INSTANCEID, CRTTIME",
            "from customershopcart",
            "where CUSTSHOPCARTID = #{custshopcartid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    CustomerShopCart selectByPrimaryKey(Long custshopcartid);

    int updateByExampleSelective(@Param("record") CustomerShopCart record, @Param("example") CustomerShopCartEx example);

    int updateByExample(@Param("record") CustomerShopCart record, @Param("example") CustomerShopCartEx example);

    int updateByPrimaryKeySelective(CustomerShopCart record);

    @Update({
            "update customershopcart",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "LIBID = #{libid,jdbcType=INTEGER},",
            "BOOKID = #{bookid,jdbcType=BIGINT},",
            "INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP}",
            "where CUSTSHOPCARTID = #{custshopcartid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(CustomerShopCart record);
}
